<template>
	<div class="print_template_container">
		<el-container class="print_template_main" style="height: 100vh;">
			<el-aside width="240px">
				<el-row>
					<el-col :span="24" class="rect-printElement-types hiprintEpContainer">
						<el-row class="drag_item_title">拖拽组件列表</el-row>
						<el-row style="height: 100px;">
							<el-col :span="12" class="drag_item_box">
								<div>
									<a class="ep-draggable-item" tid="defaultModule.text" style>
										<span class="glyphicon glyphicon-text-width" aria-hidden="true"></span>
										<p class="glyphicon-class">文本</p>
									</a>
								</div>
							</el-col>
							<el-col :span="12" class="drag_item_box" tid="defaultModule.text">
								<div>
									<a class="ep-draggable-item" tid="defaultModule.image" style>
										<span class="glyphicon glyphicon-picture" aria-hidden="true"></span>
										<p class="glyphicon-class">图片</p>
									</a>
								</div>
							</el-col>
						</el-row>
						<el-row style="height: 100px;">
							<el-col :span="12" class="drag_item_box" tid="defaultModule.text">
								<div>
									<a class="ep-draggable-item" tid="defaultModule.longText">
										<span class="glyphicon glyphicon-subscript" aria-hidden="true"></span>
										<p class="glyphicon-class">长文</p>
									</a>
								</div>
							</el-col>
							<el-col :span="12" class="drag_item_box" tid="defaultModule.text">
								<div>
									<a class="ep-draggable-item" tid="defaultModule.tableCustom" style>
										<span class="glyphicon glyphicon-th" aria-hidden="true"></span>
										<p class="glyphicon-class">表格</p>
									</a>
								</div>
							</el-col>
						</el-row>
						<el-row class="drag_item_title">辅助</el-row>
						<el-row style="height: 100px;">
							<el-col :span="12" class="drag_item_box" tid="defaultModule.text">
								<div>
									<a class="ep-draggable-item" tid="defaultModule.hline" style>
										<span class="glyphicon glyphicon-resize-horizontal" aria-hidden="true"></span>
										<p class="glyphicon-class">横线</p>
									</a>
								</div>
							</el-col>
							<el-col :span="12" class="drag_item_box" tid="defaultModule.text">
								<div>
									<a class="ep-draggable-item" tid="defaultModule.vline" style>
										<span class="glyphicon glyphicon-resize-vertical" aria-hidden="true"></span>
										<p class="glyphicon-class">竖线</p>
									</a>
								</div>
							</el-col>
						</el-row>
						<el-row style="height: 100px;">
							<el-col :span="12" class="drag_item_box" tid="defaultModule.text">
								<div>
									<a class="ep-draggable-item" tid="defaultModule.rect">
										<span class="glyphicon glyphicon-unchecked" aria-hidden="true"></span>
										<p class="glyphicon-class">矩形</p>
									</a>
								</div>
							</el-col>
							<el-col :span="12" class="drag_item_box" tid="defaultModule.text">
								<div>
									<a class="ep-draggable-item" tid="defaultModule.oval">
										<span class="glyphicon glyphicon-record" aria-hidden="true"></span>
										<p class="glyphicon-class">椭圆</p>
									</a>
								</div>
							</el-col>
						</el-row>
					</el-col>
				</el-row>
			</el-aside>
			<el-container>
				<el-header>
					<el-row style="height: 100%">
						<el-col :span="24" style="height: 100%">
							<el-button-group>
								<el-button :type="currentPaperType === 'A3' ? 'primary' : 'info'"
									@click="setPaper('A3')">A3</el-button>
								<el-button :type="currentPaperType === 'A4' ? 'primary' : 'info'"
									@click="setPaper('A4')">A4</el-button>
								<el-button :type="currentPaperType === 'A5' ? 'primary' : 'info'"
									@click="setPaper('A5')">A5</el-button>
								<el-button :type="currentPaperType === 'B3' ? 'primary' : 'info'"
									@click="setPaper('B3')">B3</el-button>
								<el-button :type="currentPaperType === 'B4' ? 'primary' : 'info'"
									@click="setPaper('B4')">B4</el-button>
								<el-button :type="currentPaperType === 'B5' ? 'primary' : 'info'"
									@click="setPaper('B5')">B5</el-button>
							</el-button-group>
							<el-popover placement="bottom" title="请输入自定义纸张宽高" trigger="click">
								<el-form ref="otherPaperForm" label-position="left" :model="otherPaper"
									label-width="30px">
									<el-row>
										<el-col :span="16">
											<el-form-item label="宽">
												<el-input v-model="otherPaper.width">
													<template slot="append">mm</template>
												</el-input>
											</el-form-item>
										</el-col>
									</el-row>
									<el-row>
										<el-col :span="16">
											<el-form-item label="高">
												<el-input v-model="otherPaper.height">
													<template slot="append">mm</template>
												</el-input>
											</el-form-item>
										</el-col>
									</el-row>
									<el-form-item>
										<el-button type="primary"
											@click="setPaper('other', otherPaper.width, otherPaper.height)">确定
										</el-button>
										<el-button @click="setPaper('other', '', '')">清空</el-button>
									</el-form-item>
								</el-form>
								<el-button slot="reference" :type="currentPaperType === 'other' ? 'primary' : 'info'">
									自定义纸张</el-button>
							</el-popover>
							<el-button-group>
								<el-button type="info" icon="el-icon-refresh-right" @click="rotatePaper">旋转</el-button>
								<el-button type="info" icon="el-icon-delete" @click="clearTemplate">清空</el-button>
							</el-button-group>
							<el-button-group>
								<el-button type="info" icon="el-icon-view" @click="previewTemplate()">快速预览</el-button>
								<el-button type="info" icon="el-icon-document" @click="getJson()">预览JSON</el-button>
								<el-button type="info" icon="el-icon-tickets" @click="getHtml(printData)">预览HTML
								</el-button>
							</el-button-group>
							<el-button-group>
								<el-button type="info" icon="el-icon-full-screen" v-if="!fullDialogStatus"
									@click="fullDialogStatus = true">全屏</el-button>
								<el-button type="info" icon="el-icon-full-screen" v-if="fullDialogStatus"
									@click="fullDialogStatus = false">正常屏幕</el-button>
							</el-button-group>
							<el-button-group>
								<el-button type="info" icon="el-icon-printer" @click="printTemplate(printData)">打印
								</el-button>
							</el-button-group>
							<el-button-group>
								<el-button type="primary" @click="hiNowPrint(printData)">直接打印</el-button>
							</el-button-group>
						</el-col>
					</el-row>
				</el-header>
				<el-main>
					<el-row>
						<el-col style="padding: 20px" :span="18" id="hiprint-printTemplate"
							class="hiprint-printTemplate"></el-col>
						<el-col :span="6" style="display:none" class="params_setting_container">
							<el-row class="hinnn-layout-sider" style="padding: 10px;">
								<div id="PrintElementOptionSetting"></div>
							</el-row>
						</el-col>
					</el-row>
					<!-- 右边抽屉 -->
					<el-drawer size="100%" class="params_drawer" :title="paramsDrawerTitle" :modal="false"
						:wrapperClosable="true" @opened="handleParamsOpened" :visible.sync="paramsDrawerStatus"
						direction="rtl">
						<h4 slot="title">参数设置: {{ paramsDrawerTitle }}</h4>
						<div id="params_content"></div>
					</el-drawer>
				</el-main>
			</el-container>
		</el-container>

		<el-dialog class="preview_dialog" ref="previewDialog" title="快速预览" @opened="handlePreviewOpened(printData)"
			:width="currentPaper.width * 1 + 'mm'" :visible.sync="previewDialogStatus">
			<div id="preview_content"></div>
			<span slot="footer" class="dialog-footer">
				<el-button @click="previewDialogStatus = false">取 消</el-button>
				<el-button type="primary" @click="previewDialogStatus = false">确 定</el-button>
			</span>
		</el-dialog>

		<el-dialog ref="infoDialog" :title="infoDialogTitle" :lock-scroll="true" :visible.sync="infoDialogStatus">
			<el-input type="textarea" :readonly="true" :autosize="{ minRows: 15}" placeholder="请输入内容"
				v-model="infoTextarea"></el-input>
			<span slot="footer" class="dialog-footer">
				<el-button @click="infoDialogStatus = false">取 消</el-button>
				<el-button type="primary" @click="infoDialogStatus = false">复 制</el-button>
			</span>
		</el-dialog>

		<el-dialog class="full_screen_dialog" :show-close="false" :visible.sync="fullDialogStatus" :modal="false"
			@opened="openFullScreen" @close="closeFullScreen" :fullscreen="true">
			<div class="full_content_container" style="width:100%; height: 100%"></div>
		</el-dialog>
	</div>
</template>

<script>
	import TaskRunner from 'concurrent-tasks';
	// 默认自定义拖拽列表
	import {
		hiprint,
		defaultElementTypeProvider,
		printData,
		customPrintJson
	} from '@/hiprint/hiprint.bundle.js'
	var hiprintTemplate;
	export default {
		data() {
			return {
				count: 13,
				printData: printData,
				testData: [],
				customPrintJson: customPrintJson,
				previewDialogStatus: false,
				paramsDrawerStatus: false,
				infoDialogStatus: false,
				fullDialogStatus: false,
				dataDialogStatus: false,
				infoTextarea: '',
				infoDialogTitle: '',
				paramsDrawerTitle: '',
				previewHtml: null,
				paperMap: {
					A3: {
						width: 420,
						height: 296.6
					},
					A4: {
						width: 210,
						height: 296.6
					},
					A5: {
						width: 210,
						height: 147.6
					},
					B3: {
						width: 500,
						height: 352.6
					},
					B4: {
						width: 250,
						height: 352.6
					},
					B5: {
						width: 250,
						height: 175.6
					}
				},
				// 纸张宽高
				currentPaper: {
					width: null,
					height: null
				},
				otherPaper: {
					width: '',
					height: ''
				}
			}
		},
		mounted() {
			this.createTemp();
		},
		computed: {
			/**
			 * @Author: dawud_yang
			 * @Desc: 处理当前选中纸张
			 */
			currentPaperType() {
				let type = null;
				if (this.otherPaper.width !== '' && this.otherPaper.height !== '') {
					type = 'other'
				} else {
					for (const key in this.paperMap) {
						let item = this.paperMap[key]
						let {
							width,
							height
						} = this.currentPaper
						if (item.width === width && item.height === height) {
							type = key
						}
					}
				}

				return type
			}
		},
		methods: {
			/**
			 * 直接打印需要安装socket客户端 可以去官网下载
			 */
			hiNowPrint(printData) {
				var arr = {
					"print_num": "11",
					"item_sku": "00001105103",
					"item_cd": "00001",
					"spec_color_val_nm": "白色BS",
					"spec_size_val_nm": "M",
					"item_nm": "53029-9508外套",
					"item_price": 1399,
					"supplier_cdnm": "53029",
					"item_season": "0004",
					"product_standard": "",
					"pro_accessory": "",
					"item_style_nm": null,
					"product_safety_indicator": null,
					"product_safety_indicator_nm": null,
					"item_mnemonic_cd": "00001105103",
					"item_catg_nm": "外套",
					"brand_nm": "美丽穿",
					"ph": "1841530299508",
					"_X_ID": "row_22"
				}
				var json =
					"{\"panels\":[{\"index\":0,\"height\":120,\"width\":107,\"paperHeader\":49.5,\"paperFooter\":340.15748031496065,\"printElements\":[{\"options\":{\"left\":108,\"top\":27,\"height\":9.75,\"width\":82.5,\"title\":\"品牌\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\",\"field\":\"BRAND_NM\",\"testData\":\"美丽穿\"},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":207,\"top\":27,\"height\":9.75,\"width\":82.5,\"title\":\"品牌\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\",\"field\":\"BRAND_NM\",\"testData\":\"美丽穿\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":27,\"height\":9.75,\"width\":82.5,\"title\":\"品牌\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\",\"field\":\"BRAND_NM\",\"testData\":\"美丽穿\"},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":108,\"top\":37.5,\"height\":21,\"width\":82.5,\"title\":\"品名\",\"field\":\"ITEM_CATG_NM\",\"testData\":\"C0032-A10连衣长裙\",\"fontSize\":7,\"lineHeight\":9.75,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":207,\"top\":37.5,\"height\":21,\"width\":82.5,\"title\":\"品名\",\"field\":\"ITEM_CATG_NM\",\"testData\":\"C0032-A10连衣长裙\",\"fontSize\":7,\"lineHeight\":9.75,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":37.5,\"height\":21,\"width\":82.5,\"title\":\"品名\",\"field\":\"ITEM_CATG_NM\",\"testData\":\"C0032-A10连衣长裙\",\"fontSize\":7,\"lineHeight\":9.75,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":58.5,\"height\":19.5,\"width\":82.5,\"title\":\"款号\",\"field\":\"ITEM_CD\",\"testData\":\"3319J0594ASDASDA\",\"fontSize\":7,\"lineHeight\":9.75,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":207,\"top\":58.5,\"height\":19.5,\"width\":82.5,\"title\":\"款号\",\"field\":\"ITEM_CD\",\"testData\":\"3319J0594ASDASDA\",\"fontSize\":7,\"lineHeight\":9.75,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":58.5,\"height\":19.5,\"width\":82.5,\"title\":\"款号\",\"field\":\"ITEM_CD\",\"testData\":\"3319J0594ASDASDA\",\"fontSize\":7,\"lineHeight\":9.75,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":79.5,\"height\":9.75,\"width\":82.5,\"title\":\"配饰\",\"field\":\"PRO_ACCESSORY\",\"testData\":\"配饰测试\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":207,\"top\":79.5,\"height\":9,\"width\":82.5,\"title\":\"配饰\",\"field\":\"PRO_ACCESSORY\",\"testData\":\"配饰测试\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":79.5,\"height\":9.75,\"width\":82.5,\"title\":\"配饰\",\"field\":\"PRO_ACCESSORY\",\"testData\":\"配饰测试\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":90,\"height\":9.75,\"width\":82.5,\"title\":\"季节\",\"field\":\"ITEM_SEASON\",\"testData\":\"05\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":207,\"top\":90,\"height\":9.75,\"width\":82.5,\"title\":\"季节\",\"field\":\"ITEM_SEASON\",\"testData\":\"05\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":90,\"height\":9.75,\"width\":82.5,\"title\":\"季节\",\"field\":\"ITEM_SEASON\",\"testData\":\"05\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":99,\"height\":9.75,\"width\":82.5,\"title\":\"风格\",\"field\":\"ITEM_STYLE_NM\",\"testData\":\"J\",\"fontFamily\":\"Microsoft YaHei\",\"fontSize\":7},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":207,\"top\":99,\"height\":9.75,\"width\":82.5,\"title\":\"风格\",\"field\":\"ITEM_STYLE_NM\",\"testData\":\"J\",\"fontFamily\":\"Microsoft YaHei\",\"fontSize\":7},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":9,\"top\":99,\"height\":9.75,\"width\":82.5,\"title\":\"风格\",\"field\":\"ITEM_STYLE_NM\",\"testData\":\"J\",\"fontFamily\":\"Microsoft YaHei\",\"fontSize\":7},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":108,\"top\":109.5,\"height\":9.75,\"width\":82.5,\"title\":\"颜色\",\"field\":\"SPEC_COLOR_VAL_NM\",\"testData\":\"黄花\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":207,\"top\":109.5,\"height\":9.75,\"width\":82.5,\"title\":\"颜色\",\"field\":\"SPEC_COLOR_VAL_NM\",\"testData\":\"黄花\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":109.5,\"height\":9.75,\"width\":82.5,\"title\":\"颜色\",\"field\":\"SPEC_COLOR_VAL_NM\",\"testData\":\"黄花\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":120,\"height\":9.75,\"width\":82.5,\"title\":\"尺码\",\"field\":\"SPEC_SIZE_VAL_NM\",\"testData\":\"S\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":207,\"top\":120,\"height\":9.75,\"width\":82.5,\"title\":\"尺码\",\"field\":\"SPEC_SIZE_VAL_NM\",\"testData\":\"S\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":120,\"height\":9.75,\"width\":82.5,\"title\":\"尺码\",\"field\":\"SPEC_SIZE_VAL_NM\",\"testData\":\"S\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":130.5,\"height\":9.75,\"width\":82.5,\"title\":\"等级\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\",\"field\":\"LEVEL\",\"testData\":\"合格品\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":207,\"top\":130.5,\"height\":9.75,\"width\":82.5,\"title\":\"等级\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\",\"field\":\"LEVEL\",\"testData\":\"合格品\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":130.5,\"height\":9.75,\"width\":82.5,\"title\":\"等级\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\",\"field\":\"LEVEL\",\"testData\":\"合格品\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":139.5,\"height\":21,\"width\":82.5,\"title\":\"主料、里料成分：详见内标\",\"fontSize\":7,\"lineHeight\":9.75,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":207,\"top\":139.5,\"height\":21,\"width\":82.5,\"title\":\"主料、里料成分：详见内标\",\"fontSize\":7,\"lineHeight\":9.75,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":139.5,\"height\":21,\"width\":82.5,\"title\":\"主料、里料成分：详见内标\",\"fontSize\":7,\"lineHeight\":9.75,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":160.5,\"height\":12,\"width\":82.5,\"title\":\"检验员：\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":207,\"top\":160.5,\"height\":12,\"width\":82.5,\"title\":\"检验员：\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":160.5,\"height\":12,\"width\":82.5,\"title\":\"检验员：\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":172.5,\"height\":9,\"width\":82.5,\"title\":\"安全类别\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\",\"field\":\"SECURITYCATEGORY\",\"testData\":\"B类\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":207,\"top\":172.5,\"height\":9.75,\"width\":82.5,\"title\":\"安全类别\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\",\"field\":\"SECURITYCATEGORY\",\"testData\":\"B类\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":172.5,\"height\":9.75,\"width\":82.5,\"title\":\"安全类别\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\",\"field\":\"SECURITYCATEGORY\",\"testData\":\"B类\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":181.5,\"height\":9.75,\"width\":82.5,\"title\":\"执行标准\",\"field\":\"PRODUCT_STANDARD\",\"fontSize\":6,\"fontFamily\":\"Microsoft YaHei\",\"testData\":\"FZ/T  81004-2012\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":207,\"top\":181.5,\"height\":9.75,\"width\":82.5,\"title\":\"执行标准\",\"field\":\"PRODUCT_STANDARD\",\"fontSize\":6,\"fontFamily\":\"Microsoft YaHei\",\"testData\":\"FZ/T  81004-2012\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":181.5,\"height\":9.75,\"width\":82.5,\"title\":\"执行标准\",\"field\":\"PRODUCT_STANDARD\",\"fontSize\":6,\"fontFamily\":\"Microsoft YaHei\",\"testData\":\"FZ/T  81004-2012\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":192,\"height\":9.75,\"width\":82.5,\"title\":\"批号\",\"field\":\"PH\",\"fontSize\":6,\"fontFamily\":\"Microsoft YaHei\",\"testData\":\"2153G0066594\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":207,\"top\":192,\"height\":9.75,\"width\":82.5,\"title\":\"批号\",\"field\":\"PH\",\"fontSize\":6,\"fontFamily\":\"Microsoft YaHei\",\"testData\":\"2153G0066594\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":192,\"height\":9.75,\"width\":82.5,\"title\":\"批号\",\"field\":\"PH\",\"fontSize\":6,\"fontFamily\":\"Microsoft YaHei\",\"testData\":\"2153G0066594\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":202.5,\"height\":28.5,\"width\":79.5,\"field\":\"ITEM_MNEMONIC_CD\",\"testData\":\"1234\",\"textType\":\"barcode\",\"textAlign\":\"center\",\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":207,\"top\":202.5,\"height\":28.5,\"width\":79.5,\"field\":\"ITEM_MNEMONIC_CD\",\"testData\":\"1234\",\"textType\":\"barcode\",\"textAlign\":\"center\",\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":10.5,\"top\":202.5,\"height\":28.5,\"width\":78,\"field\":\"ITEM_MNEMONIC_CD\",\"testData\":\"1234\",\"textType\":\"barcode\",\"textAlign\":\"center\",\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":105,\"top\":241.5,\"height\":18,\"width\":82.5,\"title\":\"统一零售价\",\"fontWeight\":\"bold\",\"textAlign\":\"center\",\"fontSize\":8.25,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":205.5,\"top\":241.5,\"height\":16.5,\"width\":81,\"title\":\"统一零售价\",\"fontWeight\":\"bold\",\"textAlign\":\"center\",\"fontSize\":9.75,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":241.5,\"height\":18,\"width\":82.5,\"title\":\"统一零售价\",\"fontWeight\":\"bold\",\"textAlign\":\"center\",\"fontSize\":9,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":106.5,\"top\":262.5,\"height\":15,\"width\":82.5,\"fontWeight\":\"bold\",\"textAlign\":\"center\",\"field\":\"ITEM_PRICE\",\"fontSize\":9,\"fontFamily\":\"Microsoft YaHei\",\"formatter\":\"function(value,templateData){ return \\\"￥\\\"+templateData; }\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":205.5,\"top\":262.5,\"height\":15,\"width\":81,\"fontWeight\":\"bold\",\"textAlign\":\"center\",\"field\":\"ITEM_PRICE\",\"fontSize\":9,\"fontFamily\":\"Microsoft YaHei\",\"formatter\":\"function(value,templateData){ return \\\"￥\\\"+templateData; }\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":262.5,\"height\":15,\"width\":81,\"fontWeight\":\"bold\",\"textAlign\":\"center\",\"field\":\"ITEM_PRICE\",\"fontSize\":9,\"fontFamily\":\"Microsoft YaHei\",\"formatter\":\"function(value,templateData){ return \\\"￥\\\"+templateData; }\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":112.5,\"top\":277.5,\"height\":21,\"width\":61.5,\"title\":\"广州玖泽品牌咨询管理有限责任公司\",\"textAlign\":\"center\",\"fontSize\":6,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":211.5,\"top\":277.5,\"height\":21,\"width\":61.5,\"title\":\"广州玖泽品牌咨询管理有限责任公司\",\"textAlign\":\"center\",\"fontSize\":6,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":13.5,\"top\":277.5,\"height\":21,\"width\":63,\"title\":\"广州玖泽品牌咨询管理有限责任公司\",\"textAlign\":\"center\",\"fontSize\":6,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":297,\"height\":9.75,\"width\":82.5,\"title\":\"联系电话：400-112-8228\",\"fontFamily\":\"Microsoft YaHei\",\"fontSize\":6},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":207,\"top\":297,\"height\":9.75,\"width\":82.5,\"title\":\"联系电话：400-112-8228\",\"fontFamily\":\"Microsoft YaHei\",\"fontSize\":6},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":9,\"top\":297,\"height\":9.75,\"width\":82.5,\"title\":\"联系电话：400-112-8228\",\"fontFamily\":\"Microsoft YaHei\",\"fontSize\":6},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":121.5,\"top\":306,\"height\":9.75,\"width\":52.5,\"field\":\"SUPPLIER_CDNM\",\"testData\":\"111\",\"fontFamily\":\"Microsoft YaHei\",\"textAlign\":\"center\",\"fontSize\":6},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":220.5,\"top\":306,\"height\":9.75,\"width\":52.5,\"field\":\"SUPPLIER_CDNM\",\"testData\":\"1111\",\"fontFamily\":\"Microsoft YaHei\",\"textAlign\":\"center\",\"fontSize\":6},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":22.5,\"top\":306,\"height\":9.75,\"width\":54,\"field\":\"SUPPLIER_CDNM\",\"testData\":\"W002999\",\"fontFamily\":\"Microsoft YaHei\",\"textAlign\":\"center\",\"fontSize\":6},\"printElementType\":{\"type\":\"text\"}}],\"paperNumberLeft\":273,\"paperNumberTop\":318,\"paperNumberDisabled\":true}]}";
				var printData = [];
				printData.push(arr);
				printData.push(arr);
				printData.push(arr);
				printData.push(arr);
				printData.push(arr);
				printData.push(arr);
				printData.push(arr);
				printData.push(arr);
				printData.push(arr);
				printData.push(arr);
				printData.push(arr);
				//初始化打印插件
				hiprint.init();
				hiprintTemplate = new hiprint.PrintTemplate({
					template: JSON.parse(json)
				});
				//分批打印
				this.testData = printData;
				this.count = printData.length; //可以打印的次数
				// -----------------------队列打印方式----------------
				// this.tasksPrint();
				
				//---------------------------------循环打印方式-----------------
				let num = 3; //一次打印数量
				let canPrint = Math.ceil(printData.length / num); // 总打印次数
				let hasPrint = 0; //累计已打印次数
				loopPrint();
				function loopPrint() {
					if (hasPrint < canPrint) {
						let ptNum = hasPrint * num;
						let arr = printData.slice(ptNum, ptNum + num);
						var json =
							"{\"panels\":[{\"index\":0,\"height\":120,\"width\":107,\"paperHeader\":49.5,\"paperFooter\":340.15748031496065,\"printElements\":[{\"options\":{\"left\":108,\"top\":27,\"height\":9.75,\"width\":82.5,\"title\":\"品牌\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\",\"field\":\"BRAND_NM\",\"testData\":\"美丽穿\"},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":207,\"top\":27,\"height\":9.75,\"width\":82.5,\"title\":\"品牌\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\",\"field\":\"BRAND_NM\",\"testData\":\"美丽穿\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":27,\"height\":9.75,\"width\":82.5,\"title\":\"品牌\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\",\"field\":\"BRAND_NM\",\"testData\":\"美丽穿\"},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":108,\"top\":37.5,\"height\":21,\"width\":82.5,\"title\":\"品名\",\"field\":\"ITEM_CATG_NM\",\"testData\":\"C0032-A10连衣长裙\",\"fontSize\":7,\"lineHeight\":9.75,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":207,\"top\":37.5,\"height\":21,\"width\":82.5,\"title\":\"品名\",\"field\":\"ITEM_CATG_NM\",\"testData\":\"C0032-A10连衣长裙\",\"fontSize\":7,\"lineHeight\":9.75,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":37.5,\"height\":21,\"width\":82.5,\"title\":\"品名\",\"field\":\"ITEM_CATG_NM\",\"testData\":\"C0032-A10连衣长裙\",\"fontSize\":7,\"lineHeight\":9.75,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":58.5,\"height\":19.5,\"width\":82.5,\"title\":\"款号\",\"field\":\"ITEM_CD\",\"testData\":\"3319J0594ASDASDA\",\"fontSize\":7,\"lineHeight\":9.75,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":207,\"top\":58.5,\"height\":19.5,\"width\":82.5,\"title\":\"款号\",\"field\":\"ITEM_CD\",\"testData\":\"3319J0594ASDASDA\",\"fontSize\":7,\"lineHeight\":9.75,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":58.5,\"height\":19.5,\"width\":82.5,\"title\":\"款号\",\"field\":\"ITEM_CD\",\"testData\":\"3319J0594ASDASDA\",\"fontSize\":7,\"lineHeight\":9.75,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":79.5,\"height\":9.75,\"width\":82.5,\"title\":\"配饰\",\"field\":\"PRO_ACCESSORY\",\"testData\":\"配饰测试\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":207,\"top\":79.5,\"height\":9,\"width\":82.5,\"title\":\"配饰\",\"field\":\"PRO_ACCESSORY\",\"testData\":\"配饰测试\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":79.5,\"height\":9.75,\"width\":82.5,\"title\":\"配饰\",\"field\":\"PRO_ACCESSORY\",\"testData\":\"配饰测试\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":90,\"height\":9.75,\"width\":82.5,\"title\":\"季节\",\"field\":\"ITEM_SEASON\",\"testData\":\"05\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":207,\"top\":90,\"height\":9.75,\"width\":82.5,\"title\":\"季节\",\"field\":\"ITEM_SEASON\",\"testData\":\"05\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":90,\"height\":9.75,\"width\":82.5,\"title\":\"季节\",\"field\":\"ITEM_SEASON\",\"testData\":\"05\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":99,\"height\":9.75,\"width\":82.5,\"title\":\"风格\",\"field\":\"ITEM_STYLE_NM\",\"testData\":\"J\",\"fontFamily\":\"Microsoft YaHei\",\"fontSize\":7},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":207,\"top\":99,\"height\":9.75,\"width\":82.5,\"title\":\"风格\",\"field\":\"ITEM_STYLE_NM\",\"testData\":\"J\",\"fontFamily\":\"Microsoft YaHei\",\"fontSize\":7},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":9,\"top\":99,\"height\":9.75,\"width\":82.5,\"title\":\"风格\",\"field\":\"ITEM_STYLE_NM\",\"testData\":\"J\",\"fontFamily\":\"Microsoft YaHei\",\"fontSize\":7},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":108,\"top\":109.5,\"height\":9.75,\"width\":82.5,\"title\":\"颜色\",\"field\":\"SPEC_COLOR_VAL_NM\",\"testData\":\"黄花\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":207,\"top\":109.5,\"height\":9.75,\"width\":82.5,\"title\":\"颜色\",\"field\":\"SPEC_COLOR_VAL_NM\",\"testData\":\"黄花\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":109.5,\"height\":9.75,\"width\":82.5,\"title\":\"颜色\",\"field\":\"SPEC_COLOR_VAL_NM\",\"testData\":\"黄花\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":120,\"height\":9.75,\"width\":82.5,\"title\":\"尺码\",\"field\":\"SPEC_SIZE_VAL_NM\",\"testData\":\"S\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":207,\"top\":120,\"height\":9.75,\"width\":82.5,\"title\":\"尺码\",\"field\":\"SPEC_SIZE_VAL_NM\",\"testData\":\"S\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":120,\"height\":9.75,\"width\":82.5,\"title\":\"尺码\",\"field\":\"SPEC_SIZE_VAL_NM\",\"testData\":\"S\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":130.5,\"height\":9.75,\"width\":82.5,\"title\":\"等级\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\",\"field\":\"LEVEL\",\"testData\":\"合格品\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":207,\"top\":130.5,\"height\":9.75,\"width\":82.5,\"title\":\"等级\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\",\"field\":\"LEVEL\",\"testData\":\"合格品\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":130.5,\"height\":9.75,\"width\":82.5,\"title\":\"等级\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\",\"field\":\"LEVEL\",\"testData\":\"合格品\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":139.5,\"height\":21,\"width\":82.5,\"title\":\"主料、里料成分：详见内标\",\"fontSize\":7,\"lineHeight\":9.75,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":207,\"top\":139.5,\"height\":21,\"width\":82.5,\"title\":\"主料、里料成分：详见内标\",\"fontSize\":7,\"lineHeight\":9.75,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":139.5,\"height\":21,\"width\":82.5,\"title\":\"主料、里料成分：详见内标\",\"fontSize\":7,\"lineHeight\":9.75,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":160.5,\"height\":12,\"width\":82.5,\"title\":\"检验员：\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":207,\"top\":160.5,\"height\":12,\"width\":82.5,\"title\":\"检验员：\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":160.5,\"height\":12,\"width\":82.5,\"title\":\"检验员：\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":172.5,\"height\":9,\"width\":82.5,\"title\":\"安全类别\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\",\"field\":\"SECURITYCATEGORY\",\"testData\":\"B类\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":207,\"top\":172.5,\"height\":9.75,\"width\":82.5,\"title\":\"安全类别\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\",\"field\":\"SECURITYCATEGORY\",\"testData\":\"B类\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":172.5,\"height\":9.75,\"width\":82.5,\"title\":\"安全类别\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\",\"field\":\"SECURITYCATEGORY\",\"testData\":\"B类\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":181.5,\"height\":9.75,\"width\":82.5,\"title\":\"执行标准\",\"field\":\"PRODUCT_STANDARD\",\"fontSize\":6,\"fontFamily\":\"Microsoft YaHei\",\"testData\":\"FZ/T  81004-2012\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":207,\"top\":181.5,\"height\":9.75,\"width\":82.5,\"title\":\"执行标准\",\"field\":\"PRODUCT_STANDARD\",\"fontSize\":6,\"fontFamily\":\"Microsoft YaHei\",\"testData\":\"FZ/T  81004-2012\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":181.5,\"height\":9.75,\"width\":82.5,\"title\":\"执行标准\",\"field\":\"PRODUCT_STANDARD\",\"fontSize\":6,\"fontFamily\":\"Microsoft YaHei\",\"testData\":\"FZ/T  81004-2012\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":192,\"height\":9.75,\"width\":82.5,\"title\":\"批号\",\"field\":\"PH\",\"fontSize\":6,\"fontFamily\":\"Microsoft YaHei\",\"testData\":\"2153G0066594\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":207,\"top\":192,\"height\":9.75,\"width\":82.5,\"title\":\"批号\",\"field\":\"PH\",\"fontSize\":6,\"fontFamily\":\"Microsoft YaHei\",\"testData\":\"2153G0066594\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":192,\"height\":9.75,\"width\":82.5,\"title\":\"批号\",\"field\":\"PH\",\"fontSize\":6,\"fontFamily\":\"Microsoft YaHei\",\"testData\":\"2153G0066594\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":202.5,\"height\":28.5,\"width\":79.5,\"field\":\"ITEM_MNEMONIC_CD\",\"testData\":\"1234\",\"textType\":\"barcode\",\"textAlign\":\"center\",\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":207,\"top\":202.5,\"height\":28.5,\"width\":79.5,\"field\":\"ITEM_MNEMONIC_CD\",\"testData\":\"1234\",\"textType\":\"barcode\",\"textAlign\":\"center\",\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":10.5,\"top\":202.5,\"height\":28.5,\"width\":78,\"field\":\"ITEM_MNEMONIC_CD\",\"testData\":\"1234\",\"textType\":\"barcode\",\"textAlign\":\"center\",\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":105,\"top\":241.5,\"height\":18,\"width\":82.5,\"title\":\"统一零售价\",\"fontWeight\":\"bold\",\"textAlign\":\"center\",\"fontSize\":8.25,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":205.5,\"top\":241.5,\"height\":16.5,\"width\":81,\"title\":\"统一零售价\",\"fontWeight\":\"bold\",\"textAlign\":\"center\",\"fontSize\":9.75,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":241.5,\"height\":18,\"width\":82.5,\"title\":\"统一零售价\",\"fontWeight\":\"bold\",\"textAlign\":\"center\",\"fontSize\":9,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":106.5,\"top\":262.5,\"height\":15,\"width\":82.5,\"fontWeight\":\"bold\",\"textAlign\":\"center\",\"field\":\"ITEM_PRICE\",\"fontSize\":9,\"fontFamily\":\"Microsoft YaHei\",\"formatter\":\"function(value,templateData){ return \\\"￥\\\"+templateData; }\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":205.5,\"top\":262.5,\"height\":15,\"width\":81,\"fontWeight\":\"bold\",\"textAlign\":\"center\",\"field\":\"ITEM_PRICE\",\"fontSize\":9,\"fontFamily\":\"Microsoft YaHei\",\"formatter\":\"function(value,templateData){ return \\\"￥\\\"+templateData; }\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":262.5,\"height\":15,\"width\":81,\"fontWeight\":\"bold\",\"textAlign\":\"center\",\"field\":\"ITEM_PRICE\",\"fontSize\":9,\"fontFamily\":\"Microsoft YaHei\",\"formatter\":\"function(value,templateData){ return \\\"￥\\\"+templateData; }\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":112.5,\"top\":277.5,\"height\":21,\"width\":61.5,\"title\":\"广州玖泽品牌咨询管理有限责任公司\",\"textAlign\":\"center\",\"fontSize\":6,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":211.5,\"top\":277.5,\"height\":21,\"width\":61.5,\"title\":\"广州玖泽品牌咨询管理有限责任公司\",\"textAlign\":\"center\",\"fontSize\":6,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":13.5,\"top\":277.5,\"height\":21,\"width\":63,\"title\":\"广州玖泽品牌咨询管理有限责任公司\",\"textAlign\":\"center\",\"fontSize\":6,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":297,\"height\":9.75,\"width\":82.5,\"title\":\"联系电话：400-112-8228\",\"fontFamily\":\"Microsoft YaHei\",\"fontSize\":6},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":207,\"top\":297,\"height\":9.75,\"width\":82.5,\"title\":\"联系电话：400-112-8228\",\"fontFamily\":\"Microsoft YaHei\",\"fontSize\":6},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":9,\"top\":297,\"height\":9.75,\"width\":82.5,\"title\":\"联系电话：400-112-8228\",\"fontFamily\":\"Microsoft YaHei\",\"fontSize\":6},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":121.5,\"top\":306,\"height\":9.75,\"width\":52.5,\"field\":\"SUPPLIER_CDNM\",\"testData\":\"111\",\"fontFamily\":\"Microsoft YaHei\",\"textAlign\":\"center\",\"fontSize\":6},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":220.5,\"top\":306,\"height\":9.75,\"width\":52.5,\"field\":\"SUPPLIER_CDNM\",\"testData\":\"1111\",\"fontFamily\":\"Microsoft YaHei\",\"textAlign\":\"center\",\"fontSize\":6},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":22.5,\"top\":306,\"height\":9.75,\"width\":54,\"field\":\"SUPPLIER_CDNM\",\"testData\":\"W002999\",\"fontFamily\":\"Microsoft YaHei\",\"textAlign\":\"center\",\"fontSize\":6},\"printElementType\":{\"type\":\"text\"}}],\"paperNumberLeft\":273,\"paperNumberTop\":318,\"paperNumberDisabled\":true}]}";
						let hiprintTemplate = new hiprint.PrintTemplate({
							template: JSON.parse(json)
						});
						hiprintTemplate.print2(arr, {
							printer: '',
							title: hasPrint
						});
						hiprintTemplate.on('printSuccess', function() {
							console.log(hasPrint+'打印完成')
							loopPrint();
						})
						hiprintTemplate.on('printError', function() {
							that.$message.error('打印失败')
						})
					}
					hasPrint++;
				}
			},
			// 队列打印
			tasksPrint() {
				// 官网/文档： https://concurrent-tasks.js.org/
				const runner = new TaskRunner();
				runner.setConcurrency(1); // 同时执行数量
				const task = []
				let that = this
				const tasksKey = `open${Date.now()}`;
				for (let i = 1; i <= this.count; i++) {
					// done -> 任务完成回调
					let key = `task${i}`;
					task.push(done => {
						let printData = this.testData[i]
						that.realPrint(runner, done, key, i, printData, tasksKey)
					})
				}
				runner.addMultiple(task)
				//this.openNotification(runner, tasksKey)
			},
			realPrint(runner, done, key, i, printData, tasksKey) {
				let that = this
				that.$message.info({
					key: key,
					placement: 'topRight',
					duration: null,
					message: `正在准备打印第 ${i} 张`,
					description: '队列运行中...',
				});
				/*let template = that.$ls.get('KEY_TEMPLATE_TASKS', panel)
				let hiprintTemplate = new hiprint.PrintTemplate({
					template: template,
				});*/
				var json =
					"{\"panels\":[{\"index\":0,\"height\":120,\"width\":107,\"paperHeader\":49.5,\"paperFooter\":340.15748031496065,\"printElements\":[{\"options\":{\"left\":108,\"top\":27,\"height\":9.75,\"width\":82.5,\"title\":\"品牌\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\",\"field\":\"BRAND_NM\",\"testData\":\"美丽穿\"},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":207,\"top\":27,\"height\":9.75,\"width\":82.5,\"title\":\"品牌\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\",\"field\":\"BRAND_NM\",\"testData\":\"美丽穿\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":27,\"height\":9.75,\"width\":82.5,\"title\":\"品牌\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\",\"field\":\"BRAND_NM\",\"testData\":\"美丽穿\"},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":108,\"top\":37.5,\"height\":21,\"width\":82.5,\"title\":\"品名\",\"field\":\"ITEM_CATG_NM\",\"testData\":\"C0032-A10连衣长裙\",\"fontSize\":7,\"lineHeight\":9.75,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":207,\"top\":37.5,\"height\":21,\"width\":82.5,\"title\":\"品名\",\"field\":\"ITEM_CATG_NM\",\"testData\":\"C0032-A10连衣长裙\",\"fontSize\":7,\"lineHeight\":9.75,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":37.5,\"height\":21,\"width\":82.5,\"title\":\"品名\",\"field\":\"ITEM_CATG_NM\",\"testData\":\"C0032-A10连衣长裙\",\"fontSize\":7,\"lineHeight\":9.75,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":58.5,\"height\":19.5,\"width\":82.5,\"title\":\"款号\",\"field\":\"ITEM_CD\",\"testData\":\"3319J0594ASDASDA\",\"fontSize\":7,\"lineHeight\":9.75,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":207,\"top\":58.5,\"height\":19.5,\"width\":82.5,\"title\":\"款号\",\"field\":\"ITEM_CD\",\"testData\":\"3319J0594ASDASDA\",\"fontSize\":7,\"lineHeight\":9.75,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":58.5,\"height\":19.5,\"width\":82.5,\"title\":\"款号\",\"field\":\"ITEM_CD\",\"testData\":\"3319J0594ASDASDA\",\"fontSize\":7,\"lineHeight\":9.75,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":79.5,\"height\":9.75,\"width\":82.5,\"title\":\"配饰\",\"field\":\"PRO_ACCESSORY\",\"testData\":\"配饰测试\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":207,\"top\":79.5,\"height\":9,\"width\":82.5,\"title\":\"配饰\",\"field\":\"PRO_ACCESSORY\",\"testData\":\"配饰测试\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":79.5,\"height\":9.75,\"width\":82.5,\"title\":\"配饰\",\"field\":\"PRO_ACCESSORY\",\"testData\":\"配饰测试\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":90,\"height\":9.75,\"width\":82.5,\"title\":\"季节\",\"field\":\"ITEM_SEASON\",\"testData\":\"05\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":207,\"top\":90,\"height\":9.75,\"width\":82.5,\"title\":\"季节\",\"field\":\"ITEM_SEASON\",\"testData\":\"05\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":90,\"height\":9.75,\"width\":82.5,\"title\":\"季节\",\"field\":\"ITEM_SEASON\",\"testData\":\"05\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":99,\"height\":9.75,\"width\":82.5,\"title\":\"风格\",\"field\":\"ITEM_STYLE_NM\",\"testData\":\"J\",\"fontFamily\":\"Microsoft YaHei\",\"fontSize\":7},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":207,\"top\":99,\"height\":9.75,\"width\":82.5,\"title\":\"风格\",\"field\":\"ITEM_STYLE_NM\",\"testData\":\"J\",\"fontFamily\":\"Microsoft YaHei\",\"fontSize\":7},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":9,\"top\":99,\"height\":9.75,\"width\":82.5,\"title\":\"风格\",\"field\":\"ITEM_STYLE_NM\",\"testData\":\"J\",\"fontFamily\":\"Microsoft YaHei\",\"fontSize\":7},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":108,\"top\":109.5,\"height\":9.75,\"width\":82.5,\"title\":\"颜色\",\"field\":\"SPEC_COLOR_VAL_NM\",\"testData\":\"黄花\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":207,\"top\":109.5,\"height\":9.75,\"width\":82.5,\"title\":\"颜色\",\"field\":\"SPEC_COLOR_VAL_NM\",\"testData\":\"黄花\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":109.5,\"height\":9.75,\"width\":82.5,\"title\":\"颜色\",\"field\":\"SPEC_COLOR_VAL_NM\",\"testData\":\"黄花\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":120,\"height\":9.75,\"width\":82.5,\"title\":\"尺码\",\"field\":\"SPEC_SIZE_VAL_NM\",\"testData\":\"S\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":207,\"top\":120,\"height\":9.75,\"width\":82.5,\"title\":\"尺码\",\"field\":\"SPEC_SIZE_VAL_NM\",\"testData\":\"S\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":120,\"height\":9.75,\"width\":82.5,\"title\":\"尺码\",\"field\":\"SPEC_SIZE_VAL_NM\",\"testData\":\"S\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":130.5,\"height\":9.75,\"width\":82.5,\"title\":\"等级\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\",\"field\":\"LEVEL\",\"testData\":\"合格品\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":207,\"top\":130.5,\"height\":9.75,\"width\":82.5,\"title\":\"等级\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\",\"field\":\"LEVEL\",\"testData\":\"合格品\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":130.5,\"height\":9.75,\"width\":82.5,\"title\":\"等级\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\",\"field\":\"LEVEL\",\"testData\":\"合格品\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":139.5,\"height\":21,\"width\":82.5,\"title\":\"主料、里料成分：详见内标\",\"fontSize\":7,\"lineHeight\":9.75,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":207,\"top\":139.5,\"height\":21,\"width\":82.5,\"title\":\"主料、里料成分：详见内标\",\"fontSize\":7,\"lineHeight\":9.75,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":139.5,\"height\":21,\"width\":82.5,\"title\":\"主料、里料成分：详见内标\",\"fontSize\":7,\"lineHeight\":9.75,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":160.5,\"height\":12,\"width\":82.5,\"title\":\"检验员：\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":207,\"top\":160.5,\"height\":12,\"width\":82.5,\"title\":\"检验员：\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":160.5,\"height\":12,\"width\":82.5,\"title\":\"检验员：\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":172.5,\"height\":9,\"width\":82.5,\"title\":\"安全类别\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\",\"field\":\"SECURITYCATEGORY\",\"testData\":\"B类\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":207,\"top\":172.5,\"height\":9.75,\"width\":82.5,\"title\":\"安全类别\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\",\"field\":\"SECURITYCATEGORY\",\"testData\":\"B类\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":172.5,\"height\":9.75,\"width\":82.5,\"title\":\"安全类别\",\"fontSize\":7,\"fontFamily\":\"Microsoft YaHei\",\"field\":\"SECURITYCATEGORY\",\"testData\":\"B类\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":181.5,\"height\":9.75,\"width\":82.5,\"title\":\"执行标准\",\"field\":\"PRODUCT_STANDARD\",\"fontSize\":6,\"fontFamily\":\"Microsoft YaHei\",\"testData\":\"FZ/T  81004-2012\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":207,\"top\":181.5,\"height\":9.75,\"width\":82.5,\"title\":\"执行标准\",\"field\":\"PRODUCT_STANDARD\",\"fontSize\":6,\"fontFamily\":\"Microsoft YaHei\",\"testData\":\"FZ/T  81004-2012\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":181.5,\"height\":9.75,\"width\":82.5,\"title\":\"执行标准\",\"field\":\"PRODUCT_STANDARD\",\"fontSize\":6,\"fontFamily\":\"Microsoft YaHei\",\"testData\":\"FZ/T  81004-2012\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":192,\"height\":9.75,\"width\":82.5,\"title\":\"批号\",\"field\":\"PH\",\"fontSize\":6,\"fontFamily\":\"Microsoft YaHei\",\"testData\":\"2153G0066594\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":207,\"top\":192,\"height\":9.75,\"width\":82.5,\"title\":\"批号\",\"field\":\"PH\",\"fontSize\":6,\"fontFamily\":\"Microsoft YaHei\",\"testData\":\"2153G0066594\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":192,\"height\":9.75,\"width\":82.5,\"title\":\"批号\",\"field\":\"PH\",\"fontSize\":6,\"fontFamily\":\"Microsoft YaHei\",\"testData\":\"2153G0066594\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":202.5,\"height\":28.5,\"width\":79.5,\"field\":\"ITEM_MNEMONIC_CD\",\"testData\":\"1234\",\"textType\":\"barcode\",\"textAlign\":\"center\",\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":207,\"top\":202.5,\"height\":28.5,\"width\":79.5,\"field\":\"ITEM_MNEMONIC_CD\",\"testData\":\"1234\",\"textType\":\"barcode\",\"textAlign\":\"center\",\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":10.5,\"top\":202.5,\"height\":28.5,\"width\":78,\"field\":\"ITEM_MNEMONIC_CD\",\"testData\":\"1234\",\"textType\":\"barcode\",\"textAlign\":\"center\",\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":105,\"top\":241.5,\"height\":18,\"width\":82.5,\"title\":\"统一零售价\",\"fontWeight\":\"bold\",\"textAlign\":\"center\",\"fontSize\":8.25,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":205.5,\"top\":241.5,\"height\":16.5,\"width\":81,\"title\":\"统一零售价\",\"fontWeight\":\"bold\",\"textAlign\":\"center\",\"fontSize\":9.75,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":241.5,\"height\":18,\"width\":82.5,\"title\":\"统一零售价\",\"fontWeight\":\"bold\",\"textAlign\":\"center\",\"fontSize\":9,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":106.5,\"top\":262.5,\"height\":15,\"width\":82.5,\"fontWeight\":\"bold\",\"textAlign\":\"center\",\"field\":\"ITEM_PRICE\",\"fontSize\":9,\"fontFamily\":\"Microsoft YaHei\",\"formatter\":\"function(value,templateData){ return \\\"￥\\\"+templateData; }\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":205.5,\"top\":262.5,\"height\":15,\"width\":81,\"fontWeight\":\"bold\",\"textAlign\":\"center\",\"field\":\"ITEM_PRICE\",\"fontSize\":9,\"fontFamily\":\"Microsoft YaHei\",\"formatter\":\"function(value,templateData){ return \\\"￥\\\"+templateData; }\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":9,\"top\":262.5,\"height\":15,\"width\":81,\"fontWeight\":\"bold\",\"textAlign\":\"center\",\"field\":\"ITEM_PRICE\",\"fontSize\":9,\"fontFamily\":\"Microsoft YaHei\",\"formatter\":\"function(value,templateData){ return \\\"￥\\\"+templateData; }\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":112.5,\"top\":277.5,\"height\":21,\"width\":61.5,\"title\":\"广州玖泽品牌咨询管理有限责任公司\",\"textAlign\":\"center\",\"fontSize\":6,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":211.5,\"top\":277.5,\"height\":21,\"width\":61.5,\"title\":\"广州玖泽品牌咨询管理有限责任公司\",\"textAlign\":\"center\",\"fontSize\":6,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":13.5,\"top\":277.5,\"height\":21,\"width\":63,\"title\":\"广州玖泽品牌咨询管理有限责任公司\",\"textAlign\":\"center\",\"fontSize\":6,\"fontFamily\":\"Microsoft YaHei\"},\"printElementType\":{\"type\":\"longText\"}},{\"options\":{\"left\":108,\"top\":297,\"height\":9.75,\"width\":82.5,\"title\":\"联系电话：400-112-8228\",\"fontFamily\":\"Microsoft YaHei\",\"fontSize\":6},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":207,\"top\":297,\"height\":9.75,\"width\":82.5,\"title\":\"联系电话：400-112-8228\",\"fontFamily\":\"Microsoft YaHei\",\"fontSize\":6},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":9,\"top\":297,\"height\":9.75,\"width\":82.5,\"title\":\"联系电话：400-112-8228\",\"fontFamily\":\"Microsoft YaHei\",\"fontSize\":6},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":121.5,\"top\":306,\"height\":9.75,\"width\":52.5,\"field\":\"SUPPLIER_CDNM\",\"testData\":\"111\",\"fontFamily\":\"Microsoft YaHei\",\"textAlign\":\"center\",\"fontSize\":6},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":220.5,\"top\":306,\"height\":9.75,\"width\":52.5,\"field\":\"SUPPLIER_CDNM\",\"testData\":\"1111\",\"fontFamily\":\"Microsoft YaHei\",\"textAlign\":\"center\",\"fontSize\":6},\"printElementType\":{\"type\":\"text\"}},{\"options\":{\"left\":22.5,\"top\":306,\"height\":9.75,\"width\":54,\"field\":\"SUPPLIER_CDNM\",\"testData\":\"W002999\",\"fontFamily\":\"Microsoft YaHei\",\"textAlign\":\"center\",\"fontSize\":6},\"printElementType\":{\"type\":\"text\"}}],\"paperNumberLeft\":273,\"paperNumberTop\":318,\"paperNumberDisabled\":true}]}";
				let hiprintTemplate = new hiprint.PrintTemplate({
					template: JSON.parse(json)
				});
				hiprintTemplate.print2(printData, {
					printer: '',
					title: key
				});
				hiprintTemplate.on('printSuccess', function() {
					let info = runner.tasks.list.length > 1 ? '准备打印下一张' : '已完成打印'
					that.$message.success({
						key: key,
						placement: 'topRight',
						message: key + ' 打印成功',
						description: info,
					});
					done()
					if (!runner.isBusy()) {
						that.$message.close(tasksKey)
					}
				})
				hiprintTemplate.on('printError', function() {
					that.$message.close(key)
					done()
					that.$message.error('打印失败，已加入重试队列中')
					runner.add(that.realPrint(runner, done, key, i, printData))
				})
			},
			/**
			 * @Author: dawud_yang
			 * @Desc: 设置纸张属性
			 * @param width 当前纸张宽度 mm
			 * @param height 当前纸张高度 mm
			 */
			setCurrentPaper(obj) {
				let {
					width,
					height
				} = obj;
				this.currentPaper.width = width;
				this.currentPaper.height = height;
			},
			/**
			 * @Author: dawud_yang
			 * @Desc: 设置纸张
			 * @param type [A3, A4, A5, B3, B4, B5, other]
			 * @param width 自定义高度
			 * @param height 自定义高度
			 */
			setPaper(type, width, height) {
				try {
					if (type === 'other') {
						if (width === '' && height === '') {
							hiprintTemplate.setPaper('A4', null);
							this.setCurrentPaper(this.paperMap['A4'])
							this.otherPaper = {
								width: '',
								height: ''
							}
						} else {
							hiprintTemplate.setPaper(width, height);
							this.setCurrentPaper({
								width: width,
								height: height
							})
						}
					} else {
						hiprintTemplate.setPaper(type, null);
						this.setCurrentPaper(this.paperMap[type])
						this.otherPaper = {
							width: '',
							height: ''
						}
					}
				} catch (error) {
					this.$message({
						message: '操作失败:' + error,
						type: 'error'
					});
				}
			},
			/**
			 * @Author: dawud_yang
			 * @Desc: 旋转
			 */
			rotatePaper() {
				try {
					hiprintTemplate.rotatePaper();
				} catch (error) {
					this.$message({
						message: '操作失败:' + error,
						type: 'error'
					});
				}
			},
			/**
			 * @Author: dawud_yang
			 * @Desc: 清除配置
			 */
			clearTemplate() {
				try {
					hiprintTemplate.clear();
				} catch (error) {
					this.$message({
						message: '操作失败:' + error,
						type: 'error'
					});
				}
			},
			/**
			 * @Author: dawud_yang
			 * @Desc: 快速预览
			 */
			previewTemplate() {
				this.previewDialogStatus = true;
			},
			/**
			 * @Author: dawud_yang
			 * @Desc: 打开预览dialog回调
			 */
			handlePreviewOpened(printData) {
				$('#preview_content').html(hiprintTemplate.getHtml(printData))
			},
			/**
			 * @Author: dawud_yang
			 * @Desc: 打印
			 */
			printTemplate(printData) {
				hiprintTemplate.print(printData);
			},
			/**
			 * @Author: dawud_yang
			 * @Desc: 设置element click事件监听
			 */
			elementAddEventListen() {
				let self = this;
				// self.paramsDrawerStatus = true;		// 打开抽屉弹框
				window.hinnn.event.on(hiprintTemplate.getPrintElementSelectEventKey(), function(t) {
					self.paramsDrawerTitle = t.printElement.printElementType.title; // 赋值标题
					self.paramsDrawerStatus = true; // 打开抽屉弹框
				})
			},
			/**
			 * @Author: dawud_yang
			 * @Desc: 参数设置drawer回调,将参数设置dom添加到弹出层中
			 */
			handleParamsOpened() {
				$('#params_content').append($('.hinnn-layout-sider'))
			},
			/**
			 * @Author: dawud_yang
			 * @Desc: 获取配置JSON
			 */
			getJson() {
				this.infoTextarea = JSON.stringify(hiprintTemplate.getJson());
				this.infoDialogTitle = '预览JSON'
				this.infoDialogStatus = true;
			},
			/**
			 * @Author: dawud_yang
			 * @Desc: 获取配置HTML
			 * @param printData
			 */
			getHtml(printData) {
				this.infoTextarea = hiprintTemplate.getHtml(printData)[0].outerHTML;
				this.infoDialogTitle = '预览HTML'
				this.infoDialogStatus = true;
			},
			/**
			 * @Author: dawud_yang
			 * @Desc: 打开全屏
			 */
			openFullScreen() {
				$('.full_content_container').append($('.print_template_main'))
			},
			/**
			 * @Author: dawud_yang
			 * @Desc: 关闭全屏
			 */
			closeFullScreen() {
				$('.print_template_container').append($('.print_template_main'))
			},
			// 获取当前时间，day为number，getDay(-1):昨天的日期;getDay(0):今天的日期;getDay(1):明天的日期;【以此类推】
			getDay(day) {
				var today = new Date();
				var targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day;
				today.setTime(targetday_milliseconds); //注意，这行是关键代码

				var tYear = today.getFullYear();
				var tMonth = today.getMonth();
				var tDate = today.getDate();
				tMonth = this.doHandleMonth(tMonth + 1);
				tDate = this.doHandleMonth(tDate);
				var tHours = today.getHours();
				var tMinutes = today.getMinutes();
				var tSeconds = today.getSeconds();
				return tYear + "-" + tMonth + "-" + tDate + " " + tHours + ":" + tMinutes + ":" + tSeconds;
			},
			// 时间格式，小于两位数的，前面添加0
			doHandleMonth(month) {
				var m = month;
				if (month.toString().length == 1) {
					m = "0" + month;
				}
				return m;
			},
			createTemp() {
				let self = this
				//初始化打印插件
				hiprint.init({
					providers: [new defaultElementTypeProvider()]
				});
				//设置左侧拖拽事件
				hiprint.PrintElementTypeManager.buildByHtml($('.ep-draggable-item'));
				var _customPrintJson = this.printTempList ? JSON.parse(this.printTempList.PRINT_JSON) : customPrintJson
				hiprintTemplate = new hiprint.PrintTemplate({
					template: _customPrintJson,
					settingContainer: '#PrintElementOptionSetting',
					paginationContainer: '.hiprint-printPagination'
				});
				//打印设计
				hiprintTemplate.design('#hiprint-printTemplate');
				self.setCurrentPaper(self.paperMap.A4);
				self.elementAddEventListen();
				$('.params_drawer').width($('.params_setting_container').width() * 1) //动态设置右部参数设置框宽度
			}
		},
	}
</script>

<style>
	@import 'https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css';

	.el-header,
	.el-footer {
		background-color: #b3c0d1;
		color: #333;
		line-height: 60px;
	}

	.el-aside {
		background-color: #d3dce6;
		color: #333;
		padding: 6px;
		margin-bottom: 0px !important;
	}

	.el-main {
		background-color: #e9eef3;
		color: #333;
		padding: 0;
	}

	.drag_item_box {
		height: 100%;
		padding: 6px;
	}

	.drag_item_box>div {
		height: 100%;
		width: 100%;
		background-color: #fff;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.drag_item_box>div>a {
		text-align: center;
		text-decoration-line: none;
	}

	.drag_item_box>div>a>span {
		font-size: 28px;
	}

	.drag_item_box>div>a>p {
		margin: 0;
	}

	.drag_item_title {
		font-size: 16px;
		padding: 12px 6px 0 6px;
		font-weight: bold;
	}

	.preview_dialog .el-dialog__body {
		padding: 0;
	}

	#params_content .container {
		width: 100% !important;
	}

	.params_drawer .el-drawer.rtl {
		overflow: auto;
	}

	.params_drawer .el-drawer__header {
		margin-bottom: 0;
	}

	.params_drawer {
		left: auto;
	}

	.hiprint-printTemplate {
		overflow-x: auto;
	}

	.hiprint-printPaper {
		background-color: #fff;
	}

	.full_screen_dialog .el-dialog__header {
		padding: 0;
		margin: 0;
	}

	.full_screen_dialog .el-dialog__body {
		padding: 0;
	}
</style>
